package de.hmm.hwip.osgi.ipc;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import de.hmm.hwip.service.FelixStarter;

/** Boot up receiver
 * receives the boot finished sign from android device and starts OSGi Service
 * @author johannes mendel
 * @version 08.11.2012
 */
public class BootUpReceiver extends BroadcastReceiver {

	//Wait 15 seconds after device restart to call service
	private static final int startTimer = 15 * 1000;

	@Override
	public void onReceive(Context context, Intent intent) {
		
		AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
		PendingIntent pi = PendingIntent.getService(context, 0, new Intent(
				context, FelixStarter.class), PendingIntent.FLAG_UPDATE_CURRENT);
		am.set(AlarmManager.RTC_WAKEUP,	System.currentTimeMillis() + startTimer, pi);
	}
}
